<?php
require_once '../../Connections/level2/L2connect.php';
require_once '../../AjaxCall_Action_Utility/convertMSG.php';

function changeShowProduct($idEncode) {
    $id = "";
    $idDecode=idDecode(KeyAction::$showkey,$idEncode); 
    if($idDecode){
       $id = $idDecode;
    }else{
      return FALSE;  
    }
    $queryExecutor = new QueryExecutor();
    $sqlCount = "SELECT count(proShow) FROM  sme_product WHERE sme_product.productId ='$id'";
    $countRecord = $queryExecutor->queryForString($sqlCount);
    if (intval($countRecord) == 1) {
        $sqlStatus = "SELECT proShow FROM  sme_product WHERE sme_product.productId ='$id'";
        $status = $queryExecutor->queryForString($sqlStatus);
        $statusChange = '1';
        if($status == '1'){
             $statusChange = '0';
        }  
        $sqlChange = "UPDATE sme_product SET proShow = '$statusChange' WHERE sme_product.productId =$id LIMIT 1 ";
        if ($queryExecutor->executeUpdate($sqlChange)) {
            $queryExecutor->close();
            return TRUE;
        } else {
            $queryExecutor->close();
            return FALSE;
        }
    } else {
        $queryExecutor->close();
        return FALSE;
    }
}


$deleteIDStatus = isset($_GET['del']);
if($deleteIDStatus){
    $deleteID = $_GET['del'];
    if(deleteProduct($deleteID)){
      echo '1'; 
    } else {
      echo '01';  
    }   
}else{
    echo '02';
}
function changeshow($id)
{
 	$ids=proDC("show",$id);
    $qr=mysql_query("SELECT proShow FROM  sme_product WHERE sme_product.productId ='$ids'") ;
	if(mysql_num_rows($qr)==1)
	  {
	  	  $rs=mysql_fetch_array($qr);
		  if($rs[0])$stt=0;else $stt=1;
		  if($ids) { 
		  mysql_query("UPDATE sme_product SET proShow = '$stt' WHERE sme_product.productId =$ids LIMIT 1 ;");
		   redirect("product.php#a$ids");	  }
	  }
	  else redirect("product.php");	
}    

?>
